package main

import "fmt"

const (
	name = "xiaowang"
)

func main() {

	defer fmt.Println("name is " + name)

	//数组
	array := []int{1, 2, 3, 4, 5}

	//自动推导创建切片
	slice := []int{}

	//借助make函数创建
	slice_make := make([]int, 0, 10)

	//切片,startIndex,endIndex(包头不包尾),capac;
	s := array[0:3:5]

	_ = append(s, 4, 5, 6, 7, 8, 9, 10)

	slice_make = append(slice_make, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)

	fmt.Println(len(s))
	fmt.Println(cap(s))
	fmt.Println(s)
	fmt.Printf("slice = %v \n", slice)
	fmt.Printf("slice_make = %v ,cap(slice_make) = %d ,len(slice_make) = %d \n", slice_make, cap(slice_make), len(slice_make))
}
